﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.Controls;
using YArchitech.LIB;
using YJKArchMethodLibrary.Utils;

namespace YArchitech.Public.ExcelToView
{
	public partial class SetNeedData : EscBaseForm
	{
		internal List<int> LstUseData
		{
			get
			{
				if (this.UseData.Count == 0)
				{
					this.UseData.Add(1);
					this.UseData.Add(Convert.ToInt32('A'));
					this.UseData.Add(Convert.ToInt32('B'));
					this.UseData.Add(Convert.ToInt32('C'));
					this.UseData.Add(Convert.ToInt32('D'));
				}
				return this.UseData;
			}
		}

		public SetNeedData()
		{
			this.SetRange();
			this.InitializeComponent();
			this.comboBox1.Items.Add("1");
			this.comboBox1.SelectedIndex = 0;
			this.comboBox2.DataSource = this.SelectRangeNum;
			this.comboBox2.SelectedIndex = 0;
			this.comboBox3.DataSource = this.SelectRangeName;
			this.comboBox3.SelectedIndex = 1;
			this.comboBox4.DataSource = this.SelectRangeType;
			this.comboBox4.SelectedIndex = 2;
			this.comboBox5.DataSource = this.SelectRangeDec;
			this.comboBox5.SelectedIndex = 3;
		}

		private void SetRange()
		{
			for (int i = 65; i < 91; i++)
			{
				this.SelectRangeNum.Add((char)i);
				this.SelectRangeName.Add((char)i);
				this.SelectRangeType.Add((char)i);
				this.SelectRangeDec.Add((char)i);
			}
		}

		private void button1_Click(object sender, EventArgs e)
		{
			if (this.GetUseData())
			{
				base.Close();
			}
		}

		private bool GetUseData()
		{
			this.UseData.Clear();
			try
			{
				this.UseData.Add(int.Parse(this.comboBox1.Text));
			}
			catch (Exception)
			{
				YJKMessageBox.Show("存在非法数值，请检查设置参数!");
				return false;
			}
			this.UseData.Add(Convert.ToInt32(Convert.ToChar(this.comboBox2.Text)));
			this.UseData.Add(Convert.ToInt32(Convert.ToChar(this.comboBox3.Text)));
			this.UseData.Add(Convert.ToInt32(Convert.ToChar(this.comboBox4.Text)));
			this.UseData.Add(Convert.ToInt32(Convert.ToChar(this.comboBox5.Text)));
			return true;
		}

		private void button2_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void SetNeedData_Load(object sender, EventArgs e)
		{
			base.Icon = Resource.YArchitechIcon;
		}

		private void comboBox1_MouseLeave(object sender, EventArgs e)
		{
			try
			{
				if (Geometry.Lessthan_Or_Equal((double)int.Parse(this.comboBox1.Text), 0.0))
				{
					YJKMessageBox.Show("请输入一个大于零的正整数.");
					this.comboBox1.Text = "1";
				}
			}
			catch (FormatException)
			{
				YJKMessageBox.Show("请输入一个大于零的正整数.");
				this.comboBox1.Text = "1";
			}
		}

		private List<char> SelectRangeNum = new List<char>();

		private List<char> SelectRangeName = new List<char>();

		private List<char> SelectRangeType = new List<char>();

		private List<char> SelectRangeDec = new List<char>();

		private List<int> SelectRow = new List<int>();

		private List<int> UseData = new List<int>();
	}
}
